Telegram Group & Telegram Channel
Calculates the date of n days ago from today.

Use datetime.date.today() to get the current day.

Use datetime.timedelta to subtract n days from today's date.


Code:


from datetime import timedelta, date

def days_ago(n):
return date.today() - timedelta(n)

EXAMPLE

days_ago(5)

Output:
date(2020, 10, 23)

Share and Support
@Python_Codes



tg-me.com/python_codes/147
Create:
Last Update:

Calculates the date of n days ago from today.

Use datetime.date.today() to get the current day.

Use datetime.timedelta to subtract n days from today's date.


Code:


from datetime import timedelta, date

def days_ago(n):
return date.today() - timedelta(n)

EXAMPLE

days_ago(5)

Output:
date(2020, 10, 23)

Share and Support
@Python_Codes

BY Python Codes


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/python_codes/147

View MORE
Open in Telegram


Python Codes Telegram | DID YOU KNOW?

Date: |

Start with a fresh view of investing strategy. The combination of risks and fads this quarter looks to be topping. That means the future is ready to move in.Likely, there will not be a wholesale shift. Company actions will aim to benefit from economic growth, inflationary pressures and a return of market-determined interest rates. In turn, all of that should drive the stock market and investment returns higher.

Python Codes from us


Telegram Python Codes
FROM USA